﻿namespace Zocono.WCS.Domain.PlcBytesObject
{
    /// <summary>
    /// 盘点报文类
    /// </summary>
    public class PlanarInventoryBO: BytesObjectBase
    {
      /// <summary>
      /// 握手类型
      /// </summary>
        public short ActionType { get; set; }
        /// <summary>
        /// 电池位置(电芯位置)
        /// </summary>
        public short BatteryIndex { get; set; }
        /// <summary>
        /// 托盘条码
        /// </summary>
        public string PalletBarcode { get; set; }

        /// <summary>
        /// 电池(电芯)条码
        /// </summary>
        public string BatteryCode { get; set; }

        /// <summary>
        /// WCS握手类型
        /// </summary>
        public short WcsActionType { get; set; }

        /// <summary>
        /// 报警代码
        /// </summary>
        public byte AlrmCode { get; set; }

        /// <summary>
        /// 预留
        /// </summary>
        public byte Reserve { get; set; }

        /// <summary>
        /// 预留2
        /// </summary>
        public short Reserve2 { get; set; }

        /// <summary>
        /// 预留3
        /// </summary>
        public short Reserve3 { get; set; }

        /// <summary>
        /// 预留4
        /// </summary>
        public short Reserve4 { get; set; }

        /// <summary>
        /// 预留5
        /// </summary>
        public short Reserve5 { get; set; }

        /// <summary>
        /// 预留6
        /// </summary>
        public short Reserve6 { get; set; }

        /// <summary>
        /// 预留7
        /// </summary>
        public short Reserve7 { get; set; }

        /// <summary>
        /// 预留8
        /// </summary>
        public short Reserve8 { get; set; }

        /// <summary>
        /// 预留9
        /// </summary>
        public short Reserve9 { get; set; }

        /// <summary>
        /// 预留10
        /// </summary>
        public short Reserve10 { get; set; }


        public override void Serialize(long plcConnectionID, long plcReadDbID, int bytesIndex, int bytesLength, int objectIndex, int objectLength, string objectType, string ScEquipmentCode, byte[] bytes)
        {

            PlcConnectionID = plcConnectionID;
            PlcReadDbID = plcReadDbID;
            BytesIndex = bytesIndex;
            BytesLength = bytesLength;
            ObjectIndex = objectIndex;
            ObjectLength = objectLength;
            ObjectType = objectType;

            
            EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();//设备号
            ActionType = HelperByte.GetIntAt(bytes, 4);//握手类型
            BatteryIndex=HelperByte.GetIntAt(bytes, 6);//电芯位置

            int length1 = HelperByte.GetSIntAt(bytes, 9);
            PalletBarcode = HelperByte.GetCharsAt(bytes, 10, length1);//托盘条码

            int length2 = HelperByte.GetSIntAt(bytes, 29);
            BatteryCode = HelperByte.GetCharsAt(bytes, 30, length2);//电池条码

            WcsActionType = HelperByte.GetIntAt(bytes, 60);
            AlrmCode = HelperByte.GetByteAt(bytes, 62);
            Reserve = HelperByte.GetByteAt(bytes, 63);
            Reserve2 = HelperByte.GetIntAt(bytes, 64);
            Reserve3 = HelperByte.GetIntAt(bytes, 66);
            Reserve4 = HelperByte.GetIntAt(bytes, 68);
            Reserve5 = HelperByte.GetIntAt(bytes, 70);
            Reserve6 = HelperByte.GetIntAt(bytes, 72);
            Reserve7 = HelperByte.GetIntAt(bytes, 74);
            Reserve8 = HelperByte.GetIntAt(bytes, 76);
            Reserve9 = HelperByte.GetIntAt(bytes, 78);
            Reserve10 = HelperByte.GetIntAt(bytes, 80);
        }
    }
}
